<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY css SYSTEM "../phaidros.css">
]>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

<!-- main HTML template -->
<xsl:template match="/">
<xsl:variable name="file" select="//response/@file"/>
<xsl:variable name="versionId" select="//response/@id"/>
<xsl:variable name="groupId" select="//response/@groupId"/>
<xsl:variable name="shortName" select="//response/@shortName"/>
<xsl:variable name="longName" select="//response/@longName"/>
<xsl:variable name="backup" select="//response/@backup"/>
<xsl:variable name="editVersionTitle" select="*/strings/string[@name='EditVersionTitle']/@value"/>
<xsl:variable name="belongsToGroupPrompt" select="*/strings/string[@name='BelongsToGroupPrompt']/@value"/>
<xsl:variable name="shortNamePrompt" select="*/strings/string[@name='ShortNamePrompt']/@value"/>
<xsl:variable name="longNamePrompt" select="*/strings/string[@name='LongNamePrompt']/@value"/>
<xsl:variable name="backupPrompt" select="*/strings/string[@name='BackupPrompt']/@value"/>
<html>
<head>
<style type="text/css">
&css;
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript">
function submitVersion( action )
{
	var groupIdField = document.getElementById("GroupId");
	var shortNameField = document.getElementById("ShortName");
	var longNameField = document.getElementById("LongName");
	var backupField = document.getElementById("Backup");
	var groupPopup = document.getElementById("GroupPopup");
	var backupPopup = document.getElementById("BackupPopup");
	var shortNameTextBox = document.getElementById("ShortNameTextBox");
	var longNameTextBox = document.getElementById("LongNameTextBox");
	groupIdField.value = groupPopup.options[groupPopup.selectedIndex].value;
	backupField.value = backupPopup.options[backupPopup.selectedIndex].value;
	shortNameField.value = shortNameTextBox.value;
	longNameField.value = longNameTextBox.value;
	document.submission.action = action;
	document.submission.submit();
}
function updateBackup( action )
{
	var backupPopup = document.getElementById("BackupPopup");
	if ( backupPopup.selectedIndex != 0 )
	{
		var nameField = document.getElementById("ShortName");
		var ok = confirm( "This will make "+nameField.value+" a partial version" );
		if ( ok )
			submitVersion( action );
		else
			backupPopup.selectedIndex = 0;
	}
	else
		submitVersion( action );
}
</script>
</head>
<body>
<form name="submission" action="/Alpha/EditVersions" method="post">
<table class="group" width="50%">
<!-- title row that says "Editing Version X" -->
<tr>
<th colspan="2">
<xsl:value-of select="concat($editVersionTitle,' ',$shortName)"/>
</th>
</tr>
<!-- short name row -->
<tr>
<td align="right">
<xsl:value-of select="$shortNamePrompt"/>: 
</td>
<td align="left">
<input type="text" id="ShortNameTextBox">
	<xsl:attribute name="value">
		<xsl:value-of select="$shortName"/>
	</xsl:attribute>
</input>
</td>
</tr>
<!-- long name row -->
<tr>
<td align="right">
<xsl:value-of select="$longNamePrompt"/>: 
</td>
<td align="left">
<input type="text" size="64" id="LongNameTextBox">
	<xsl:attribute name="value">
		<xsl:value-of select="$longName"/>
	</xsl:attribute>
</input>
</td>
</tr>
<!-- belongs to group row -->
<tr>
<td align="right">
<xsl:value-of select="$belongsToGroupPrompt"/>: 
</td>
<td align="left">
<select onchange="submitVersion('/Alpha/EditVersions/EditVersion')" id="GroupPopup">
<xsl:for-each select="//group">
	<option>
		<xsl:attribute name="value">
			<xsl:value-of select="@id"/>
		</xsl:attribute>
		<xsl:if test="@id=$groupId">
			<xsl:attribute name="selected">
				<xsl:value-of select="selected"/>
			</xsl:attribute>
		</xsl:if>
		<xsl:value-of select="@name"/>
	</option>
</xsl:for-each>
</select>
</td>
</tr>
<!-- backup version row -->
<tr>
<td align="right">
<xsl:value-of select="$backupPrompt"/>: 
</td>
<td align="left">
<select onchange="updateBackup('/Alpha/EditVersions/EditVersion')" id="BackupPopup">
	<option value="0">NO BACKUP</option>
	<xsl:if test="$backup=0">
		<xsl:attribute name="selected">selected</xsl:attribute>
	</xsl:if>
<xsl:for-each select="//version">
	<option>
		<xsl:attribute name="value">
			<xsl:value-of select="@id"/>
		</xsl:attribute>
		<xsl:if test="@id=$backup">
			<xsl:attribute name="selected">
				<xsl:value-of select="selected"/>
			</xsl:attribute>
		</xsl:if>
		<xsl:value-of select="@name"/>
	</option>
</xsl:for-each>
</select>
</td>
</tr>
<tr><td/><td align="center"><input type="button" onclick="submitVersion('/Alpha/EditVersions')" value="OK"/></td></tr>
</table>
<!-- submission fields -->
<input type="hidden" name="ShortName" id="ShortName">
	<xsl:attribute name="value"><xsl:value-of select="$shortName"/></xsl:attribute>
</input>
<input type="hidden" name="GroupId" id="GroupId"><xsl:attribute name="value"><xsl:value-of select="$groupId"/></xsl:attribute></input>
<input type="hidden" name="ParentId" id="ParentId" value="0"/>
<input type="hidden" name="Backup" id="Backup" value="0"/>
<input type="hidden" name="Version1" id="VersionId">
	<xsl:attribute name="value"><xsl:value-of select="$versionId"/></xsl:attribute>
</input>
<input type="hidden" name="ShortName" id="ShortName"/>
<input type="hidden" name="LongName" id="LongName"/>
<input type="hidden" name="Command" value="ChangeVersion"/>
<input type="hidden" name="File" id="File">
	<xsl:attribute name="value"><xsl:value-of select="$file"/></xsl:attribute>
</input>
</form>
</body>
</html>
</xsl:template>

</xsl:stylesheet>